Skip to content

Conversation

@adamdickmeiss
Copy link
Contributor

The replaceAll for looking back whether the " was escaped did not work as the preceding backslash could have been the result of escaping a backslash itself.

A follow up for #5

The replaceAll for looking back whether the " was escaped did not
work as the preceding backslash could have been the result of
escaping a backslash itself.

A follow up for #5

static String maybeQuote(String str) {
if (str == null)
if (str == null) {
Copy link
Contributor

@jakub-id jakub-id Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamdickmeiss this function name is confusing since it both quotes and escapes. Btw, we should do the same in cql-go.

Copy link
Contributor Author

@adamdickmeiss adamdickmeiss Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, the function name is bad.

There will never be a bare " as the result of a query in the current form. But it did happen in latest release until #5. This is just extra precaution to ensure that if it is bare, it will be escaped. That's all.

if (ch == '"' && !escaped) {
sb.append('\\');
}
escaped = ch == '\\' && !escaped;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamdickmeiss what if \ is on the last position like in x\

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be left as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the resulting query will be invalid no?

@adamdickmeiss adamdickmeiss merged commit efaf5ae into master Feb 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants